// auxlib.cpp

#include "auxlib.h"
#include <iostream>
#include <cmath>
using namespace std;

/////////////////////////////////////////////////////////////////////
//
// global functions
//
/////////////////////////////////////////////////////////////////////
void myAssert(bool b) {
	if (!b)
		cout << "=== myAssert fail ===" << endl;
}

bool nearEqual(double x, double y, double eps) {
	return (::std::fabs(x-y) < eps);
}


/////////////////////////////////////////////////////////////////
//
// MyClock
//
/////////////////////////////////////////////////////////////////


void MyClock::checkDiffTime() 
{
	m_finish = clock();
	m_duration = (double)(m_finish - m_start) / CLOCKS_PER_SEC;
}

void MyClock::markTime() 
{
	m_start = clock();
}

// constructor
MyClock::MyClock() 
{ 
	markTime(); 
}

double MyClock::getDiffTime() 
{
	checkDiffTime();
	return m_duration;
}

void MyClock::printDiffTime() 
{
	checkDiffTime();
	::std::cout.precision(2);
	::std::cout << "Elapsed time (in seconds) is " << getDiffTime() << ::std::endl;
	// myCout << "Elapsed time (in seconds) is " << ::std::endl;
}


